package com.doitedu.day04.funcs
import scala.collection.immutable

/**
 * @Date 22.6.23
 * @Created by HANGGE
 * @Description
 */
object _09Scan {
  def main(args: Array[String]): Unit = {

    val ls = List[String]("a" , "b" , "c" , "d")
    ls.mkString


    val str: String = ls.fold("hello")(_ + "-" + _)
    println(str)
  // 计算逻辑和fold一样  有初始值 , 保留了计算过程
    val str2: immutable.Seq[String] = ls.scan("hello")(_ + "-" + _)
    str2.foreach(println)

    val arr = Array[Int](1,2,3,4,5)
    arr.scan(10)(_+_).foreach(println)


   //默认值的数据类型和集合中的元素的类型保持一致
    val arr2 = Array[Int](1,2,3,4,5)

   //  arr2.scan(10.0)((x1,x2)=>x1.toDouble+x2.toDouble).foreach(println)
  }

}
